package org.hamster.common.components.pagination.simple
{
	import org.hamster.common.components.pagination.base.BasePagination;
	
	import spark.components.Label;
	
	public class SimplePagination extends BasePagination
	{
		private var currentPageLabel:Label;
		
		[Embed(source="images/downArrow.png")]
		private var DOWN_ARROW:Class;
		[Embed(source="images/downArrowDisabled.png")]
		private var DOWN_ARROW_DISABLED:Class;
		[Embed(source="images/downArrowDown.png")]
		private var DOWN_ARROW_DOWN:Class;
		[Embed(source="images/downArrowOver.png")]
		private var DOWN_ARROW_OVER:Class;
		[Embed(source="images/upArrow.png")]
		private var UP_ARROW:Class;
		[Embed(source="images/upArrowDisabled.png")]
		private var UP_ARROW_DISABLED:Class;
		[Embed(source="images/upArrowDown.png")]
		private var UP_ARROW_DOWN:Class;
		[Embed(source="images/upArrowOver.png")]
		private var UP_ARROW_OVER:Class;
		
		public function SimplePagination()
		{
			super();
			
			this.setStyle('upBtnSkin',           UP_ARROW);
			this.setStyle('upBtnSkinDisabled',   UP_ARROW_DISABLED);
			this.setStyle('upBtnSkinDown',       UP_ARROW_DOWN);
			this.setStyle('upBtnSkinOver',       UP_ARROW_OVER);
			this.setStyle('downBtnSkin',         DOWN_ARROW);
			this.setStyle('downBtnSkinDisabled', DOWN_ARROW_DISABLED);
			this.setStyle('downBtnSkinDown',     DOWN_ARROW_DOWN);
			this.setStyle('downBtnSkinOver',     DOWN_ARROW_OVER);
		}
		
		override protected function commitPageSize():void
		{
			super.commitPageSize();
			updatePageLabel();
		}
		
		override protected function commitCurrentPage():void
		{
			super.commitCurrentPage();
			updatePageLabel();
		}
		
		override protected function createChildren():void
		{
			super.createChildren();
			
			currentPageLabel = new Label();
			currentPageLabel.maxDisplayedLines = 1;
			updatePageLabel();
			_upPageButton.width  = 11;
			_upPageButton.height = 11;
			_dnPageButton.width  = 11;
			_dnPageButton.height = 11;
			this.addElement(_dnPageButton);
			this.addElement(currentPageLabel);
			this.addElement(_upPageButton);
		}
		
		protected function updatePageLabel():void
		{
			currentPageLabel.text = (currentPage + 1) + " / " + pageSize;
		}
		
		
	}
	
}